export const useFormPro = (props, emits) => {
  const formRef = ref(null)
  const state = reactive({
    title: '',
    showFlag: false,
    loadingFlag: false,
    submitFlag: false,
  })
  function setState(key, value) {
    state[key] = value
  }
  function onClose() {
    state.showFlag = false
  }
  function onValidate(e) {
    e.preventDefault()
    formRef.value.validate((errors) => {
      if (!errors) {
        emits('submit', props.modelForm)
      }
    })
  }
  return {
    state,
    formRef,
    setState,
    onClose,
    onValidate,
  }
}
